package day019.ioStream;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileInputStreamDemo4 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("D:\\ideaProjects\\javase_code\\study-practice\\" +
                "src\\day019\\ioStream\\day019_demo\\dog.jpg");
        FileOutputStream fos = new FileOutputStream("D:\\ideaProjects\\javase_code\\study-practice\\" +
                "src\\day019\\ioStream\\day019_demo\\test2.jpg");

        int by;
        try {
            while ((by = fis.read()) != -1) {
                fos.write(by);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
